home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / vol6n17.arc / QP-GW.ASM < prev    next >
Assembly Source File  |  1987-09-04  |  4KB  |  83 lines

  1. ;QPRINT.ASM - performs Quick Printing in the BASIC interpreter
  2. ;Note: Assemble this with MASM (2.0 or later), then LINK, finally EXE2BIN
  3. ;Copyright 1987, Ziff Communications Co.
  4.  
  5. Code        Segment Byte
  6.             Assume  CS:Code
  7.  
  8. QPrint      Proc    Far
  9. Start_Addr  Equ   $             ;identify the program's starting address
  10.  
  11. Begin:      DB    0FDh          ;fake the header BASIC uses for BLOAD
  12.             DW    0, 0          ;phony segment and address
  13.             DW    End_Addr - Start_Addr    ;calculate this program's length
  14.  
  15.             Push  BP            ;save registers for BASIC
  16.             Push  ES
  17.  
  18.             Mov   AH,3          ;specify BIOS service to read cursor position
  19.             Mov   BH,0          ;on text page zero
  20.             Int   10h           ;this service returns row/column in DH/DL
  21.  
  22.             Mov   AL,DH         ;put the current row number into AL
  23.             Mov   CL,160        ;multiply by 160 to get start address of row
  24.             Mul   CL            ;do the multiplication, answer ends up in AX
  25.             Mov   DH,0          ;clear DH for the Add below, we only want DL
  26.             Add   AX,DX         ;add the column once for the character byte
  27.             Add   AX,DX         ;and once more for the attribute byte
  28.             Mov   DI,AX         ;now DI holds starting address on the screen
  29.  
  30.             Xor   DX,DX         ;zero out DX to look at low memory using ES
  31.             Mov   ES,DX
  32.             Mov   BX,0B000h     ;assume the mono screen segment for now
  33.             Mov   AL,ES:[463h]  ;look at the video controller port address
  34.             Cmp   AL,0B4h       ;is it mono?
  35.             JZ    Get_Params    ;yes, skip over adding 800h to video segment
  36.             Add   BX,800h       ;no, adjust BX for a color monitor
  37.             Push  BX            ;and save it because the EGA test destroys BX
  38.  
  39.             Mov   AH,12h        ;specify EGA BIOS EGA special function service
  40.             Mov   BL,10h        ;request EGA info
  41.             Int   10h           ;call the BIOS
  42.             Cmp   BL,10h        ;if BL is still 10h, there's no EGA
  43.             JNZ   EGA           ;it is an EGA, skip ahead
  44.             Mov   DX,3DAh       ;not EGA, specify port to check for retrace
  45.  
  46. EGA:        Pop   BX            ;get the video segment again
  47.  
  48. Get_Params: Mov   BP,SP         ;get stack pointer so we can find variables
  49.             Mov   ES,BX         ;move whatever segment is correct into ES
  50.  
  51.             Mov   SI,[BP+08]    ;get the color that was passed
  52.             Mov   AH,[SI]       ;and put it into AH for screen writing below
  53.             Mov   SI,[BP+10]    ;put descriptor to X$ into SI
  54.             Mov   CL,[SI]       ;put Len(X$) into CL for loop counter
  55.             Mov   CH,0          ;clear out CH
  56.             JCXZ  Exit          ;if CX is zero it's a null string, exit now
  57.             Mov   SI,[SI+01]    ;put address of first character in X$ into SI
  58.             Cld                 ;clear the direction flag to move data forward
  59.  
  60. Check_Mon:  Cmp   DL,0          ;are we on a mono or EGA system?
  61.             JZ    Mono          ;yes, skip over the retrace stuff
  62.  
  63. No_Retrace: In    AL,DX         ;get the video status byte from port number DX
  64.             Test  AL,1          ;test just the horizontal retrace bit
  65.             JNZ   No_Retrace    ;if doing a retrace, wait until it's not
  66.  
  67. Retrace:    In    AL,DX         ;get the status byte again
  68.             Test  AL,1          ;are we doing a retrace now?
  69.             JZ    Retrace       ;no, wait until we are
  70.  
  71. Mono:       Lodsb               ;get the character from X$ and increment SI
  72.             Stosw               ;store both the character and attribute
  73.             Loop  Check_Mon     ;loop until CX is zero
  74.  
  75. Exit:       Pop   ES            ;restore the registers for BASIC
  76.             Pop   BP
  77.             Ret   4             ;return skipping the passed parameters
  78.  
  79. End_Addr    Equ   $             ;identify this program's ending address
  80. QPrint      Endp
  81. Code        Ends
  82.             End   Begin
  83.